//
//  OldPasswordStepController.m
//  WuJieLive
//
//  Created by 张瀚坤 on 2017/10/30.
//  Copyright © 2017年 zhk. All rights reserved.
//

#import "OldPasswordStepController.h"
#import "IdentityStepController.h"

@interface OldPasswordStepController ()
@property (weak, nonatomic) IBOutlet UILabel *lable;
@property (nonatomic , strong) HKPasswordTF * tf;
@property (weak, nonatomic) IBOutlet UIView *bgView;
@property (weak, nonatomic) IBOutlet UIButton *nextBtn;
@property (nonatomic , strong) NSString * tempPassword;
@end

@implementation OldPasswordStepController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

-(void)setNavi
{
    self.title = @"修改支付密码";
}

-(void)setUI
{
    self.view.backgroundColor =  Color(245, 245, 245);
    self.tf = [[HKPasswordTF alloc]init];
    self.tf.elementCount = 6;
    self.tf.elementMargin = 6;
    self.tf.elementBorderColor = TextLessImportColor;
    [self.bgView addSubview:self.tf];
    [self.tf mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(15);
        make.right.offset(-15);
        make.top.equalTo(self.lable.mas_bottom).offset(15);
        make.bottom.offset(-15);
    }];
    __weak typeof(self) weakSelf = self;
    self.tf.passwordDidChangeBlock = ^(NSString *password) {
        if (password.length == 6) {
            weakSelf.nextBtn.userInteractionEnabled = YES;
            [weakSelf.nextBtn setBackgroundColor:MainColor];
            weakSelf.tempPassword = password;
        }else
        {
            [weakSelf.nextBtn setBackgroundColor:MainBtnColor];
            weakSelf.nextBtn.userInteractionEnabled = NO;
        }
    };
}


- (IBAction)nextAction:(id)sender {
    
    [MBProgressHUD showHUDAddedTo:self.view animated:YES];
    NSDictionary * dict = @{@"token":self.userToken};
    [HTTPTool POSTForm:[NSString stringWithFormat:@"%@deposit-account/check-id-payment-password",BaseUrl] para:dict success:^(BOOL isSuccess, id responseObject) {
        if (isSuccess) {
            NSDictionary * dic = @{@"token":self.userToken,@"old_payment_password":self.tempPassword};
            [HTTPTool POSTForm:[NSString stringWithFormat:@"%@deposit-account/check-id-payment-password",BaseUrl] para:dic success:^(BOOL isSuccess, id responseObject) {
                [MBProgressHUD hideHUDForView:self.view animated:YES];
                if (isSuccess) {
                    IdentityStepController * vc = [[IdentityStepController alloc]init];
                    vc.labelText = @"验证旧密码";
                    [self.navigationController pushViewController:vc animated:YES];
                }
            } failure:^(NSError *error) {
                [MBProgressHUD hideHUDForView:self.view animated:YES];
            }];
        }
    } failure:^(NSError *error) {
        [MBProgressHUD hideHUDForView:self.view animated:YES];
    }];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
